This 404 seems unavoidable - what am I doing wrong? [Ninject 2.0 with ASP.NET MVC 2 on .NET 4]

Posted by Tomas Lycken on Stack Overflow See other posts from Stack Overflow or by Tomas Lycken
Published on 2010-04-01T21:45:29Z Indexed on 2010/04/01 21:53 UTC
Read the original article Hit count: 475

I downloaded the fairly new Ninject 2.0 and Ninject.Web.Mvc (targeting mvc2) sources today, and successfully built them against .NET 4 (release configuration). When trying to run an application using Ninject 2.0, i keep getting 404 errors and I can't figure out why.

This is my global.asax.cs (slightly shortified, for brevity):

using ...
using Ninject;
using Ninject.Web.Mvc;
using Ninject.Modules;

namespace Booking.Web
{
    public class MvcApplication : NinjectHttpApplication
    {        
        protected override void OnApplicationStarted()
        {
            Booking.Models.AutoMapperBootstrapper.Initialize();
            RegisterAllControllersIn(Assembly.GetExecutingAssembly());
            base.OnApplicationStarted();
        }

        protected void RegisterRoutes(RouteCollection routes)
        {
            ...
            routes.MapRoute(
                "Default",
                "{controller}/{action}/{id}",
                new { controller = "Entry", action = "Index", id = "" }
            );    
        }

        protected override IKernel CreateKernel()
        {
            INinjectModule[] mods = new INinjectModule[] {...};
            return new StandardKernel(mods);
        }
    }
}

The EntryController exists, and has an Index method that simply does a return View(). I have debugged, and verified that the call to RegisterAllControllersIn() is executed. I have also tried to use Phil Haacks Routing debugger but I still get a 404.

What do I do to find the cause of this?

© Stack Overflow or respective owner

Related posts about ninject-2

Related posts about ninject.web